package com.ruoyi.smart.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smart.domain.SmartIdChangeRecord;
import com.ruoyi.smart.service.ISmartIdChangeRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ID更改记录Controller
 * 
 * @author minwei
 * @date 2022-04-07
 */
@RestController
@RequestMapping("/smart/record")
public class SmartIdChangeRecordController extends BaseController
{
    @Autowired
    private ISmartIdChangeRecordService smartIdChangeRecordService;

    /**
     * 查询ID更改记录列表
     */
    @PreAuthorize("@ss.hasPermi('smart:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmartIdChangeRecord smartIdChangeRecord)
    {
        startPage();
        List<SmartIdChangeRecord> list = smartIdChangeRecordService.selectSmartIdChangeRecordList(smartIdChangeRecord);
        return getDataTable(list);
    }

    /**
     * 导出ID更改记录列表
     */
    @PreAuthorize("@ss.hasPermi('smart:record:export')")
    @Log(title = "ID更改记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmartIdChangeRecord smartIdChangeRecord)
    {
        List<SmartIdChangeRecord> list = smartIdChangeRecordService.selectSmartIdChangeRecordList(smartIdChangeRecord);
        ExcelUtil<SmartIdChangeRecord> util = new ExcelUtil<SmartIdChangeRecord>(SmartIdChangeRecord.class);
        util.exportExcel(response, list, "ID更改记录数据");
    }

    /**
     * 获取ID更改记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('smart:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(smartIdChangeRecordService.selectSmartIdChangeRecordById(id));
    }

    /**
     * 新增ID更改记录
     */
    @PreAuthorize("@ss.hasPermi('smart:record:add')")
    @Log(title = "ID更改记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmartIdChangeRecord smartIdChangeRecord)
    {
        return toAjax(smartIdChangeRecordService.insertSmartIdChangeRecord(smartIdChangeRecord));
    }

    /**
     * 修改ID更改记录
     */
    @PreAuthorize("@ss.hasPermi('smart:record:edit')")
    @Log(title = "ID更改记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmartIdChangeRecord smartIdChangeRecord)
    {
        return toAjax(smartIdChangeRecordService.updateSmartIdChangeRecord(smartIdChangeRecord));
    }

    /**
     * 删除ID更改记录
     */
    @PreAuthorize("@ss.hasPermi('smart:record:remove')")
    @Log(title = "ID更改记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smartIdChangeRecordService.deleteSmartIdChangeRecordByIds(ids));
    }
}
